package com.jl.jlapp.mvp.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

import com.jl.jlapp.R;
import com.jl.jlapp.mvp.activity.GoodsDetailActivity;

public class GoodsDetailFragment extends Fragment {
    GoodsDetailActivity goodsDetailActivity;
    int goodsId = 0;
    View view;
    WebView webView;

    public void onAttach(Activity paramActivity) {
        super.onAttach(paramActivity);
        this.goodsDetailActivity = ((GoodsDetailActivity) getActivity());
        this.goodsId = this.goodsDetailActivity.goodsId.intValue();
    }

    public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle) {
        this.view = paramLayoutInflater.inflate(R.layout.fragment_goods_detail, paramViewGroup, false);
        this.webView = ((WebView) this.view.findViewById(R.id.show_goods_detail_web));
        WebSettings webSettings = this.webView.getSettings();
        Log.d("aaaaaaaa", "webviewGoodsId:" + this.goodsId);
        webSettings.setSaveFormData(false);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setLoadWithOverviewMode(true);
        this.webView.setWebViewClient(new WebViewClient());
        this.webView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
        this.webView.loadUrl("http://117.158.178.202:8001/JLMIS/junlin/mis_jsp/webview/goodsDetails.jsp?goodsId=" + this.goodsId);
        return this.view;
    }

    final class DemoJavaScriptInterface {
        DemoJavaScriptInterface() {
        }

        @JavascriptInterface
        public int GetLat() {
            return GoodsDetailFragment.this.goodsId;
        }

        @JavascriptInterface
        public void clickOnAndroid(String paramString) {
            Toast.makeText(GoodsDetailFragment.this.getActivity(), paramString, Toast.LENGTH_SHORT).show();
        }

        @JavascriptInterface
        public void hrefToChooseAddressPage() {
            Toast.makeText(GoodsDetailFragment.this.getActivity(), "加载了", Toast.LENGTH_LONG).show();
        }

        @JavascriptInterface
        public void showToast(String paramString) {
            Toast.makeText(GoodsDetailFragment.this.getActivity(), paramString,  Toast.LENGTH_LONG).show();
        }
    }

    final class MyWebChromeClient
            extends WebChromeClient {
        MyWebChromeClient() {
        }

        public boolean onJsAlert(WebView paramWebView, String paramString1, String paramString2, JsResult paramJsResult) {
            Log.d("webview", paramString2);
            paramJsResult.confirm();
            return true;
        }
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/fragment/GoodsDetailFragment.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */